/*
 * Project Name spring-boot-tools
 * File Name AutoCreateAwarePost
 * Package Name com.huxiaosu.tools.autocreate
 * Create Time 2024/7/12
 * Create by name：liujie
 */
package com.huxiaosu.tools.autocreate;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.Aware;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * 加载处理器；处理 AutoCreateAware
 *
 * @author liujie
 * @date 2024/7/12 22:13
 */
@Slf4j
public class AutoCreateAwarePostprocess implements BeanPostProcessor{

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof Aware){
            if(bean instanceof AutoCreateAware autoCreateAware){
                autoCreateAware.execute();
            }
        }
        return bean;
    }
}
